package com.controller;

import com.vo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by zc on 2017/6/11.
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @RequestMapping(value = "/user",method = RequestMethod.POST)
    public User updateUser(User user,@RequestParam String name){
        System.out.println(user);
        user.setName("POST");
        System.out.println(name+"-----"+user.getAge());
        return user;
    }

    @RequestMapping(value = "/user/{userId}",method = RequestMethod.PUT)
    public User updateUser(User user, @PathVariable Integer userId){
        System.out.println(userId+"-------");
        System.out.println(user);
        user.setName("PUT");
        System.out.println(user.getName()+"-----"+user.getAge());
        return user;
    }


    @RequestMapping(value = "/user/{userId}",method = RequestMethod.DELETE)
    public User deteleUser(User user, @PathVariable Integer userId,@RequestParam(required = false) Boolean isAll){
        if (isAll!=null&&isAll){
            System.out.println("-----All-DELETE-------");
        }
        System.out.println(userId+"-------");
        System.out.println(user);
        user.setName("DELETE");
        System.out.println(user.getName()+"-----"+user.getAge());
        return user;
    }


}
